# 交换2个变量数字

# 解法一：使用临时变量
a = 5
b = 2

c = a
a = b
b = c
print("a=%d" % a)
print("b=%d" % b)

# 解法二：不使用临时变量
a = 5
b = 2

a = a + b  # a => ab
b = a - b  # b=> ab-b => a
a = a - b  # a= ab-a => b
print("a=%d" % a)
print("b=%d" % b)

# 解法三：python 解法，使用多返回值的方式
a = 5
b = 2
# a, b = (b, a)
a, b = b, a  # tuple可以省略括号先
print("a=%d" % a)
print("b=%d" % b)
